<?php 
	$_helper = $this->helper('catalog/output');
	$_product = $this->getProduct(); 
	$fromUrl = $this->getSubmitUrl($_product);
	$fromUrl = str_replace("wishlist/index","ajaxcart/wishlist",str_replace("checkout","ajaxcart",$fromUrl));
?>
<script type="text/javascript">
    //<![CDATA[
    optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
	//]]>
</script>
<div class="em_ajaxcart_view">
	<div class="product_title">
		<?php if($_product->getTypeId() == 'grouped'): ?>
			<h3><span><?php echo $this->__("This is a %s product",$_product->getTypeId()) ?></span></h3>
			<h3><span><?php echo $this->__("Please specify the quantity of product(s).") ?></span></h3>
		<?php else : ?>
			<h3><span><?php echo $this->__("This is a %s product",$_product->getTypeId()) ?></span></h3>
			<h3><span><?php echo $this->__("Please specify product option(s).") ?></span></h3>
		<?php endif ?>
	</div>
	<div class="product_view">
		<form action="<?php echo $fromUrl ?>" method="post" id="ajc_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
			<div class="no-display">
				<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
				<input type="hidden" name="related_product" id="related-products-field" value="" />
			</div>

			<div class="product-shop">
				<?php if($this->hasOptions()):?>
					<div style="display:none">
						<?php echo $this->getChildHtml('product_type_data') ?>
					</div>
				<?php endif;?>

				<?php if ($_product->isSaleable() && $this->hasOptions()):?>
					<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
				<?php endif;?>

				<?php if ($_product->isSaleable() && $this->hasOptions()):?>
					<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
				<?php endif;?>

				<?php if (!$this->hasOptions()):?>
					<?php echo $this->getChildHtml('product_type_data') ?>
					<div class="add-to-box">
						<?php if($_product->isSaleable()): ?>
							<?php echo $this->getChildHtml('addtocart') ?>
						<?php endif; ?>
					</div>
					<?php echo $this->getChildHtml('extra_buttons') ?>
				<?php endif; ?>

			</div>

			<div class="clearer"></div>
		</form>
	</div>
</div>
<script type="text/javascript">
//<![CDATA[
	ajcAddToCartForm = new VarienForm('ajc_addtocart_form');
	ajcAddToCartForm.submit = function(button, url) {
		if (this.validator.validate()) {
			var form = this.form;
			var oldUrl = form.action;

			if (url) {
			   form.action = url;
			}
			var e = null;
			try {
				this.form.submit();
			} catch (e) {
			}
			this.form.action = oldUrl;
			if (e) {
				throw e;
			}

			if (button && button != 'undefined') {
				button.disabled = true;
			}
		}
	}.bind(ajcAddToCartForm);

	ajcAddToCartForm.submitLight = function(button, url){
		if(this.validator) {
			var nv = Validation.methods;
			delete Validation.methods['required-entry'];
			delete Validation.methods['validate-one-required'];
			delete Validation.methods['validate-one-required-by-name'];
			// Remove custom datetime validators
			for (var methodName in Validation.methods) {
				if (methodName.match(/^validate-datetime-.*/i)) {
					delete Validation.methods[methodName];
				}
			}

			if (this.validator.validate()) {
				if (url) {
					this.form.action = url;
				}
				this.form.submit();
			}
			Object.extend(Validation.methods, nv);
		}
	}.bind(ajcAddToCartForm);
//]]>
</script>